/**
 * 
type: 
  200=>是代表文件夹，500=>是代表普通的文件,600=>链接
  200=>对应文件夹的icon。
  600=>对应链接的icon。
  500=>判断有没有=>thumbnail字段
    背景的大图：
      有 thumbnail=> 请求后端接口获取缩略图
      无 thumbnail=> 调用一个方法:<img src= ${matchSuffixType(extensionName, 500)} />
    左下角的小图
      有 url => <img src= ${matchSuffixType(extensionName)} />
      无 url => null
 */

export enum matchType {
  "icon-a-CannotPreview" = "icon-a-CannotPreview",
}

export const matchLargeType = (fileName: string) => {
  // 后缀获取
  let suffix = "";
  // 获取类型结果
  let result: boolean | string = "";
  if (!fileName) {
    // return 'qita_48.png'
    return undefined;
  }
  try {
    let flieArr = fileName.split(".");
    suffix = flieArr[flieArr.length - 1];
  } catch (err) {
    suffix = "";
  }
  // fileName无后缀返回 false
  if (!suffix) {
    // result = false;
    // return result;
    return undefined;
  }
  // 图片格式
  var imglist = ["png", "jpg", "jpeg", "bmp", "gif"];
  // 进行图片匹配
  result = imglist.some(function (item) {
    return item == suffix;
  });
  if (result) {
    result = "picture_48.png";
    // return result
    return "icon-a-file-jpg2";
  }
  // 匹配txt
  var txtlist = ["txt"];
  result = txtlist.some(function (item) {
    return item == suffix;
  });
  if (result) {
    result = "text_48.png";
    // return result
    return "icon-file-Excel";
  }
  // 匹配 excel
  var excelist = ["xls", "xlsx"];
  result = excelist.some(function (item) {
    return item == suffix;
  });
  if (result) {
    result = "excel_48.png";
    // return result
    return "icon-file-Excel";
  }
  // 匹配 word
  var wordlist = ["doc", "docx"];
  result = wordlist.some(function (item) {
    return item == suffix;
  });
  if (result) {
    result = "word_48.png";
    // return result
    return "icon-file-Word";
  }
  // 匹配 pdf
  var pdflist = ["pdf"];
  result = pdflist.some(function (item) {
    return item == suffix;
  });
  if (result) {
    result = "pdf_48.png";
    // return result
    return "icon-file-PDF";
  }
  // 匹配 ppt
  var pptlist = ["ppt", "pptx"];
  result = pptlist.some(function (item) {
    return item == suffix;
  });
  if (result) {
    result = "ppt_48.png";
    // return result;
    return "icon-file-PPT";
  }
  // 匹配 视频 'avi', 'wmv'
  var videolist = ["mp4", "m2v", "mkv", "3gp", "rmvb", "flv", "mov"];
  result = videolist.some(function (item) {
    return item == suffix;
  });
  if (result) {
    result = "video_48.png";
    // return result
    return "icon-file-mp4";
  }
  // 匹配 音频
  // var radiolist = ['mp3', 'wav', 'wmv']
  // result = radiolist.some(function (item) {
  //   return item == suffix
  // })
  // if (result) {
  //   result = 'radio'
  //   return result
  // }
  // 其他 文件类型
  result = "qita_48.png";
  //   return result
  return undefined;
};

export const matchSuffixType = (suffix: string, type: number) => {
  if (type == 600 || type === 4) {
    // return 'link_48.png'
    return "icon-file-jpg";
  }
  if (type === 200) {
    // if (!suffix && type === 200) {
    // return 'folder_48.png'
    return "icon-file-folder-team";
  }
  return matchLargeType(suffix);
};
